import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-05-22
 * Time: 15:43
 */
public class Test2 {

    public static void f1(int[] arr){
        arr=new int[]{10,20,30,40,50};
        arr[0]=99;
    }
    public static void f2(int[] arr){
        arr[0]=99;
    }

    public static void main(String[] args) {
        int[] arr=new int[]{1,2,3,4,5};
        f1(arr);
        arr=null;

    }
    public static void main1(String[] args) {
        int[] arr=new int[]{10,20,30,40,50};
        //1.使用下标进行访问
        System.out.println(arr[0]);

        //2.遍历数组
        int n=arr.length;
        //普遍的for循环遍历
        for(int i=0;i<n;i++)
            System.out.print(arr[i]+" ");
        System.out.print('\n');
        //for-each遍历数组
        for(int x:arr)
            System.out.print(x+" ");
        System.out.print('\n');

        //3.数组是引用类型
        int[] nums1=new int[]{1,2,3,4,5};
        int[] nums2=new int[]{10,20,30,40,50};
        nums1=nums2;
        for(int x:nums1)
            System.out.print(x+" ");
    }
}
